home *** CD-ROM | disk | FTP | other *** search
- property ioFieldList, iFieldFocus, ioFIeldFocus, iCurrentMotionStyleIndex, iCurrentVisualStyleIndex, ikMotionRightToLeft, ikMotionLeftToRight, ikMotionUp, ikMotionDown, iFirstTime, iSaveSeconds, iSaveFPS, iSaveBaseline, iSaveDelayEnter, iSaveMark, iSaveCycles
-
- on birth me
- global goBannersText, goSeconds, goFPS, goBaseline, goDelayEnter, goCycles
- set ioFieldList to [goBannersText, goSeconds, goFPS, goBaseline, goDelayEnter, goCycles]
- set ikMotionRightToLeft to 1
- set ikMotionLeftToRight to 2
- set ikMotionUp to 3
- set ikMotionDown to 4
- set iCurrentMotionStyleIndex to ikMotionRightToLeft
- set iCurrentVisualStyleIndex to 1
- set iFieldFocus to 1
- set iFirstTime to 1
- return me
- end
-
- on mInit me
- global goSeconds, goFPS, goBaseline, goDelayEnter, goCycles, goBanners, goMarkFrame, goVisualStyles, goMotionStyles, goScoreMgr
- mInit(goMarkFrame, 4)
- if iFirstTime then
- mSetValue(goSeconds, 5)
- mSetValue(goFPS, 5)
- set defaultBaseLine to integer(mGetStageHeight(goScoreMgr) / 2)
- mSetValue(goBaseline, defaultBaseLine)
- mSetValue(goDelayEnter, 0)
- mSetValue(goCycles, 1)
- mSetValue(goMarkFrame, 1)
- set iFirstTime to 0
- else
- mSetValue(goSeconds, iSaveSeconds)
- mSetValue(goFPS, iSaveFPS)
- mSetValue(goBaseline, iSaveBaseline)
- mSetValue(goDelayEnter, iSaveDelayEnter)
- mSetValue(goCycles, iSaveCycles)
- mSetValue(goMarkFrame, iSaveMark)
- end if
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- set goMotionStyles to 0
- set goMotionStyles to birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
- if the machineType < 256 then
- mInit(goVisualStyles, the number of member "BannersVisualStylesMac", iCurrentVisualStyleIndex, 8, 19)
- else
- mInit(goVisualStyles, the number of member "BannersVisualStylesPC", iCurrentVisualStyleIndex, 8, 19)
- end if
- set the keyDownScript to "mCheckKey(goBanners)"
- end
-
- on mSetFieldFocus me, oWhom
- set where to getOne(ioFieldList, oWhom)
- if where = 0 then
- alert("Internal error - mSetFieldFocus could not find object")
- return
- end if
- set iFieldFocus to where
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- end
-
- on mCheckKey me
- if the key = TAB then
- set iFieldFocus to IncrMod(iFieldFocus, count(ioFieldList))
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- pass()
- else
- if iFieldFocus = 1 then
- pass()
- else
- if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
- pass()
- else
- dontPassEvent()
- end if
- end if
- end if
- end
-
- on mSetNewMotionStyle me, theNewStyleIndex
- set iCurrentMotionStyleIndex to theNewStyleIndex
- end
-
- on mSetNewVisualStyle me, theNewStyleIndex
- set iCurrentVisualStyleIndex to theNewStyleIndex
- end
-
- on mValidate me
- set lastFieldOKFlag to mValidate(ioFIeldFocus)
- return lastFieldOKFlag
- end
-
- on mCreate me
- global goMarkFrame, goMotionStyles, goVisualStyles, goScoreMgr, goCastMgr, gDevelopmentFlag, gCastNumTextAsBitmap, goPlatform
- if not mValidate(me) then
- return
- end if
- if field "BannersText" = EMPTY then
- alert("Please enter some text for the banner.")
- return
- end if
- tell the stage
- set theStageFrame to the frame
- end tell
- set castNumVisualStyle to mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
- set theVisualStyleName to the name of cast castNumVisualStyle
- set theFont to word 2 of theVisualStyleName
- set theSize to word 3 of theVisualStyleName
- set theSeconds to integer(field "Seconds")
- set fps to integer(field "FPS")
- set nFrames to integer(theSeconds * fps)
- set baseLine to integer(field "BaseLine")
- set delayEnter to integer(field "DelayEnter")
- set nCycles to integer(field "Cycles")
- set markFirst to mGetValue(goMarkFrame)
- set nTotalFrames to nFrames * nCycles
- if not mInit(goScoreMgr, nTotalFrames, 1) then
- return
- end if
- set theCh to mGetNextSelectedChannel(goScoreMgr)
- set theFrameNum to mGetStartFrame(goScoreMgr)
- set castNumSource to mModifyRichTextCM(goCastMgr, the text of field "BannersText", theFont, theSize)
- if castNumSource = 0 then
- return
- end if
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumSource
- set widthOfTextAsBitmap to the width of member gCastNumTextAsBitmap
- set heightOfTextAsBitmap to the height of member castNumSource / the number of lines in the text of member castNumSource
- if (iCurrentMotionStyleIndex = ikMotionRightToLeft) or (iCurrentMotionStyleIndex = ikMotionLeftToRight) then
- set yStart to baseLine
- set yEnd to baseLine
- set yInc to 0
- if iCurrentMotionStyleIndex = ikMotionRightToLeft then
- set xStart to mGetStageRight(goScoreMgr) + 10
- set xEnd to 0 - widthOfTextAsBitmap - 10
- set xInc to float(xEnd - xStart) / float(nFrames)
- else
- set xStart to 0 - widthOfTextAsBitmap - 10
- set xEnd to mGetStageRight(goScoreMgr) + 10
- set xInc to float(xEnd - xStart) / float(nFrames)
- end if
- else
- set xStart to (mGetStageWidth(goScoreMgr) / 2) - (widthOfTextAsBitmap / 2)
- set xEnd to xStart
- set xInc to 0
- if iCurrentMotionStyleIndex = ikMotionUp then
- set yStart to mGetStageHeight(goScoreMgr) + heightOfTextAsBitmap + 1
- set yEnd to 0 - heightOfTextAsBitmap - 10
- set yInc to float(yEnd - yStart) / float(nFrames)
- else
- set yStart to 0 - heightOfTextAsBitmap - 10
- set yEnd to mGetStageHeight(goScoreMgr) + heightOfTextAsBitmap + 10
- set yInc to float(yEnd - yStart) / float(nFrames)
- end if
- end if
- set theForeColor to 255
- set theBackColor to 0
- set castNumTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumSource)
- tell the stage
- pasteClipBoardInto(member castNumTarget)
- set the name of member castNumTarget to "RichText" && string(the ticks)
- end tell
- set frameList to []
- repeat with i = theFrameNum to theFrameNum + nTotalFrames - 1
- add(frameList, [i])
- end repeat
- if markFirst then
- set firstFrame to getAt(frameList, 1)
- set theLabel to "AW.Banner." & word 1 of the text of field "BannersText" & " " & mGetGeneratedScoreSelection(goScoreMgr)
- add(firstFrame, [#label, theLabel])
- setAt(frameList, 1, firstFrame)
- end if
- set relFrameCount to 1
- repeat with thisCycle = 1 to nCycles
- set firstFrame to getAt(frameList, relFrameCount)
- set secondFrame to getAt(frameList, relFrameCount + 1)
- if delayEnter > 0 then
- add(firstFrame, [#tempo, -delayEnter])
- add(secondFrame, [#tempo, fps])
- else
- add(firstFrame, [#tempo, fps])
- add(secondFrame, [#tempo, 0])
- end if
- setAt(frameList, relFrameCount, firstFrame)
- setAt(frameList, relFrameCount + 1, secondFrame)
- set xLoc to xStart
- set yLoc to yStart
- repeat with thisFrame = 1 to nFrames
- set xLoc to integer(xLoc + 0.49000000000000005)
- set yLoc to integer(yLoc + 0.49000000000000005)
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- set xLoc to xLoc + xInc
- set yLoc to yLoc + yInc
- end repeat
- end repeat
- mWriteFrame(goScoreMgr, frameList)
- set labelName to "Banners" & goPlatform
- go(label(labelName) + 2)
- if not gDevelopmentFlag then
- tell the stage
- go(theStageFrame)
- end tell
- end if
- mClean(goScoreMgr)
- end
-
- on mCleanUp me
- global goMotionStyles, goSeconds, goFPS, goBaseline, goDelayEnter, goCycles, goMarkFrame
- mCleanUp(goMotionStyles)
- set iSaveSeconds to mGetValue(goSeconds)
- set iSaveFPS to mGetValue(goFPS)
- set iSaveBaseline to mGetValue(goBaseline)
- set iSaveDelayEnter to mGetValue(goDelayEnter)
- set iSaveCycles to mGetValue(goCycles)
- set iSaveMark to mGetValue(goMarkFrame)
- mCleanUp(goMarkFrame)
- end
-